using System;
using System.Data;
using System.Collections.Generic;
using ADOBase;

namespace eTMS.DAO{
	/********************************BEGIN GiaoVienNgayNghiDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:25/02/2012 41:11:06</para>
	/// <para>Class Name: GiaoVienNgayNghiDAO</para>
	/// <para>Description: Class access to table GiaoVienNgayNghi in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class GiaoVienNgayNghiDAO : DAOBase<GiaoVienNgayNghiEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: GiaoVienNgayNghi_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int GiaoVienNgayNghi_ID){
			string strSQL="SELECT  [GiaoVienNgayNghi_ID],[GiaoVien_ID],[Thu_ID],[TietHoc_ID] FROM [GiaoVienNgayNghi]  WHERE [GiaoVienNgayNghi].[GiaoVienNgayNghi_ID]=@GiaoVienNgayNghi_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",GiaoVienNgayNghi_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: GiaoVienNgayNghi_ID</para>
		/// <para>Output: GiaoVienNgayNghiEntity</para>
		///</summary>
		public GiaoVienNgayNghiEntity SelectOne(int GiaoVienNgayNghi_ID){
			IDbCommand cmd=this.CreateSelectOneCommand(GiaoVienNgayNghi_ID);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [GiaoVienNgayNghi_ID],[GiaoVien_ID],[Thu_ID],[TietHoc_ID] FROM [GiaoVienNgayNghi] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [GiaoVienNgayNghi_ID],[GiaoVien_ID],[Thu_ID],[TietHoc_ID] FROM [GiaoVienNgayNghi]  WHERE [GiaoVienNgayNghi].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of GiaoVienNgayNghiEntity</para>
		///</summary>
		public List<GiaoVienNgayNghiEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [GiaoVienNgayNghi_ID],[GiaoVien_ID],[Thu_ID],[TietHoc_ID] FROM [GiaoVienNgayNghi]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [GiaoVienNgayNghi_ID],[GiaoVien_ID],[Thu_ID],[TietHoc_ID] FROM [GiaoVienNgayNghi]  WHERE [GiaoVienNgayNghi].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of GiaoVienNgayNghiEntity</para>
		///</summary>
		public List<GiaoVienNgayNghiEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(GiaoVienNgayNghiEntity o){
			string strSQL="INSERT INTO [GiaoVienNgayNghi]([GiaoVien_ID],[Thu_ID],[TietHoc_ID]) VALUES  (@GiaoVien_ID,@Thu_ID,@TietHoc_ID);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullGiaoVien_ID)
				this.CreateCommandParameter(cmd,"@GiaoVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GiaoVien_ID",o.GiaoVien_ID);

			if(o.IsNullThu_ID)
				this.CreateCommandParameter(cmd,"@Thu_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Thu_ID",o.Thu_ID);

			if(o.IsNullTietHoc_ID)
				this.CreateCommandParameter(cmd,"@TietHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TietHoc_ID",o.TietHoc_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: Save</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(GiaoVienNgayNghiEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.GiaoVienNgayNghi_ID=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of GiaoVienNgayNghiEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<GiaoVienNgayNghiEntity>list){
			foreach(GiaoVienNgayNghiEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(GiaoVienNgayNghiEntity o){
			string strSQL="UPDATE  [GiaoVienNgayNghi] SET [GiaoVienNgayNghi].[GiaoVien_ID]=@GiaoVien_ID,[GiaoVienNgayNghi].[Thu_ID]=@Thu_ID,[GiaoVienNgayNghi].[TietHoc_ID]=@TietHoc_ID WHERE [GiaoVienNgayNghi].[GiaoVienNgayNghi_ID]=@GiaoVienNgayNghi_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullGiaoVienNgayNghi_ID)
				this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",o.GiaoVienNgayNghi_ID);

			if(o.IsNullGiaoVien_ID)
				this.CreateCommandParameter(cmd,"@GiaoVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GiaoVien_ID",o.GiaoVien_ID);

			if(o.IsNullThu_ID)
				this.CreateCommandParameter(cmd,"@Thu_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Thu_ID",o.Thu_ID);

			if(o.IsNullTietHoc_ID)
				this.CreateCommandParameter(cmd,"@TietHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TietHoc_ID",o.TietHoc_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,GiaoVienNgayNghi_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int GiaoVienNgayNghi_ID){
			string strSQL="UPDATE  [GiaoVienNgayNghi] SET [GiaoVienNgayNghi].["+ColumnName+"]=@ColumnName WHERE [GiaoVienNgayNghi].[GiaoVienNgayNghi_ID]=@GiaoVienNgayNghi_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",GiaoVienNgayNghi_ID);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: Update</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(GiaoVienNgayNghiEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of GiaoVienNgayNghiEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<GiaoVienNgayNghiEntity>list){
			foreach(GiaoVienNgayNghiEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: UpdateGiaoVien_ID</para>
		/// <para>Input: NewGiaoVien_ID,GiaoVienNgayNghi_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGiaoVien_ID(int NewGiaoVien_ID,int GiaoVienNgayNghi_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GiaoVien_ID",NewGiaoVien_ID,GiaoVienNgayNghi_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: UpdateThu_ID</para>
		/// <para>Input: NewThu_ID,GiaoVienNgayNghi_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateThu_ID(int NewThu_ID,int GiaoVienNgayNghi_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Thu_ID",NewThu_ID,GiaoVienNgayNghi_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: UpdateTietHoc_ID</para>
		/// <para>Input: NewTietHoc_ID,GiaoVienNgayNghi_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTietHoc_ID(int NewTietHoc_ID,int GiaoVienNgayNghi_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TietHoc_ID",NewTietHoc_ID,GiaoVienNgayNghi_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [GiaoVienNgayNghi]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(GiaoVienNgayNghiEntity o){
			string strSQL="DELETE   FROM [GiaoVienNgayNghi]   WHERE [GiaoVienNgayNghi].[GiaoVienNgayNghi_ID]=@GiaoVienNgayNghi_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullGiaoVienNgayNghi_ID)
				this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",o.GiaoVienNgayNghi_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: GiaoVienNgayNghi_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int GiaoVienNgayNghi_ID){
			string strSQL="DELETE   FROM [GiaoVienNgayNghi]   WHERE [GiaoVienNgayNghi].[GiaoVienNgayNghi_ID]=@GiaoVienNgayNghi_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@GiaoVienNgayNghi_ID",GiaoVienNgayNghi_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [GiaoVienNgayNghi]   WHERE [GiaoVienNgayNghi].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: Delete</para>
		/// <para>Input: GiaoVienNgayNghiEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(GiaoVienNgayNghiEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: GiaoVienNgayNghi_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int GiaoVienNgayNghi_ID){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(GiaoVienNgayNghi_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select join to GiaoVienThuTrongTuanTietHoc functions
		#endregion

		#region Select join to GiaoVien functions
		#endregion

		#region Select join to ThuTrongTuan functions
		#endregion

		#region Select join to TietHoc functions
		#endregion

		#region Select,delete by GiaoVienNgayNghi_ID functions
		#endregion

		#region Select,delete by GiaoVien_ID functions
		#endregion

		#region Select,delete by Thu_ID functions
		#endregion

		#region Select,delete by TietHoc_ID functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:25/02/2012 41:11:06</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: GiaoVienNgayNghiEntity</para>
		///</summary>
		protected override GiaoVienNgayNghiEntity MapObject(IDataReader r){
			GiaoVienNgayNghiEntity entity = new GiaoVienNgayNghiEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("GiaoVienNgayNghi_ID");
						if (!r.IsDBNull(ordinal)) entity.GiaoVienNgayNghi_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GiaoVien_ID");
						if (!r.IsDBNull(ordinal)) entity.GiaoVien_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Thu_ID");
						if (!r.IsDBNull(ordinal)) entity.Thu_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TietHoc_ID");
						if (!r.IsDBNull(ordinal)) entity.TietHoc_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END GiaoVienNgayNghiDAOBase*****************************************/
	/*****************************************************************************************************/
}

